package Util;

import org.apache.commons.mail.DefaultAuthenticator;
import org.apache.commons.mail.Email;
import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

import Model.EmailBean;

public class EmailUtil {
	
	 public static void sendTextMail(EmailBean eBean){   
	        Email email = new SimpleEmail();      
	        email.setHostName(eBean.getHostName());   
	        email.setSmtpPort(eBean.getPort());   
	        email.setAuthenticator(new DefaultAuthenticator(eBean.getSenderId(),eBean.getSenderPassword()));   
	        email.setTLS(true);   
	        try {   
	            email.setFrom(eBean.getSenderId());   
	            email.setMsg(eBean.getContent());   
	            email.addTo(eBean.getDestinationAddress());   
	            email.setSubject(eBean.getSubject());   
	            email.send();                  
	        } catch (EmailException e) {   
	            e.printStackTrace();   
	        }   
	    }   

}
